package com.example.databasedoc.config;

import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;

/**
 * DataSourceProvider
 *
 * @author lijunsong
 * @date 2021/3/12 17:56
 * @since 1.0
 */
public class DataSourceProvider {
    public static HikariDataSource create(DataSourceReq dataSourceReq) {
        HikariConfig hikariConfig = new HikariConfig();
        hikariConfig.setJdbcUrl(dataSourceReq.getUrl());
        hikariConfig.setUsername(dataSourceReq.getUsername());
        hikariConfig.setPassword(dataSourceReq.getPassword());
        hikariConfig.setDriverClassName("com.mysql.cj.jdbc.Driver");
        return new HikariDataSource(hikariConfig);
    }
}
